package tests;
import static org.junit.Assert.*;
import javax.swing.JFrame;
import net.miginfocom.swing.MigLayout;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import view.*;
/**
 * This class tests the AppView class.
 * @author buthainahaldosary 
 * @since May 2013
 * @version $Revision: 1.0 $
 */


public class TestAppView {

	AppView av;
	/**
	 * This method is called before every test case to setup a new AppView.
	 */
	@Before
	public void setUp()
	{
	av=new AppView();
	}
	
	/**
	 * This method is called after every test case to tear down the AppView and force 
	 * garbage collection.
	 */
	@After
	public void tearDown()
	{
		av=null;
		System.gc();
		
	}
	/**
	 * This test case tests the basic AppView properties (title and default close operation).
	 */
	@Test
	public void testBasicAppViewProperties() {
	assertEquals("CoolMail", av.getTitle());
	assertEquals(JFrame.EXIT_ON_CLOSE,av.getDefaultCloseOperation());
	}
	
	/**
	 * This test case tests the MainMenuView component by initializing a new main menu and checking it's type.
	 */
	@Test
	public void testMainMenuView()
	{
		MainMenuView mv=new MainMenuView();
		assertEquals((av.getMainMenu()) instanceof MainMenuView,mv instanceof MainMenuView);
	}
	
	/**
	 * This test case tests the NavigationView component by initializing a new navigation view and checking it's type.
	 */
	@Test
	public void testNavigationView()
	{
		NavigationView nv=new NavigationView((new MigLayout("fillx")));
		assertEquals((av.getNavigation()) instanceof NavigationView,nv instanceof NavigationView);
	}
	
	/**
	 * This test case tests the ListingView component by initializing a new listing view and checking it's type.
	 */
	@Test
	public void testListingView()
	{
		ListingView lv=new ListingView((new MigLayout("fillx")));
		assertEquals((av.getListing()) instanceof ListingView,lv instanceof ListingView);
	}

	/**
	 * This test case tests the PreviewView component by initializing a new preview view and checking it's type.
	 */
	@Test
	public void testPreviewView()
	{
		PreviewView pv = new PreviewView(new MigLayout("fillx"));
		assertEquals((av.getPreview()) instanceof PreviewView,pv instanceof PreviewView);
	}
}
